package com.cheer.enums;

import com.cheer.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 参评文件类型
 */
@Getter
@AllArgsConstructor
public enum ReferenceFileEnum {

    RECOMMEND(1, "推荐表", "pdf", 10*1024*1024L),
    STORY(2, "事迹材料", "doc, docx", 5*1024*1024L),
    EVIDENCE(3, "佐证图片", "png, jpg, gif, JPG",5*1024*1024L);

    private final Integer code;
    private final String message;
    private final String fileExt;
    private final Long size;


    public static ReferenceFileEnum getType(Integer type){

        ReferenceFileEnum[] values = ReferenceFileEnum.values();
        for (int i = 0; i < values.length; i++) {
            ReferenceFileEnum value = values[i];
            if(value.getCode().equals(type)){
                return value;
            }
        }
        return null;
    }

    public static Boolean isStandard( ReferenceFileEnum referenceFileEnum, String fileExt ){

        return referenceFileEnum.getFileExt().contains(fileExt);
    }

    public Boolean isOverSize(Long fileSize){

        int i = fileSize.compareTo(this.getSize());

        return i == 1;
    }





}
